import request from '@/utils/request'; // 假设存在一个request工具函数
import axios from 'axios';

// 获取考试列表
export function getExams(params?: any) {
  return request({
    url: '/api/exams',
    method: 'get',
    params,
  });
}

// 获取考试详情
export function getExamDetail(examId: number) {
  return request({
    url: `/api/exams/${examId}`,
    method: 'get',
  });
}

// 创建考试
export function createExam(data: any) {
  return request({
    url: '/api/exams',
    method: 'post',
    data,
  });
}

// 更新考试
export function updateExam(examId: number, data: any) {
  return request({
    url: `/api/exams/${examId}`,
    method: 'put',
    data,
  });
}

// 删除考试
export function deleteExam(examId: number) {
  return request({
    url: `/api/exams/${examId}`,
    method: 'delete',
  });
}

// 更新考试状态
export function updateExamStatus(examId: number, status: number) {
  return request({
    url: `/api/exams/${examId}/status`,
    method: 'put',
    params: { status },
  });
}

// 获取考试的作弊事件列表
export function getCheatingEvents(examId: number) {
  return request({
    url: `/api/exams/${examId}/cheating-events`,
    method: 'get',
  });
}

// 获取作弊事件证据
export function getCheatingEvidence(examId: number, eventId: number) {
  return request({
    url: `/api/exams/${examId}/cheating-events/${eventId}/evidence`,
    method: 'get',
  });
}

// --- 新增监控相关API ---

// 获取考试统计数据
export function getExamStatistics(examId: number) {
  return request({
    url: `/api/exams/${examId}/statistics`,
    method: 'get',
  });
}

// 获取考试作弊统计计数
export function getCheatingStatistics(examId: number) {
  return request({
    url: `/api/exams/${examId}/cheating-events/stats`,
    method: 'get',
  });
}

// 获取考试实时监控数据
export function getRealTimeMonitorData(examId: number) {
  return request({
    url: `/api/exams/${examId}/real-time-monitor`,
    method: 'get',
  });
}

// 获取特定学生在考试中的最新截图
export function getLatestStudentScreenshot(examId: number, studentId: number) {
  return request({
    url: `/api/exams/${examId}/screenshots/latest`,
    method: 'get',
    params: { studentId },
  });
}

// 获取成绩分析数据
export function getGradeAnalysis(examId: number) {
  return axios.get('/api/exams/grade/analysis', {
    params: { examId }
  });
}

// 获取考试列表
export function getExamList() {
  return request({
    url: '/api/exams',
    method: 'get'
  })
}

// TODO: Add API calls for exam questions, student grades and other monitoring actions (like marking cheating, ignoring event)
